package com.heima.wemedia.controller.v1;

import com.heima.api.wemedia.WmUserControllerApi;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.media.pojos.WmNews;
import com.heima.model.media.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Title: TODO
 * @Description: TODO
 * @author: 丁丁
 * @date: 2021/3/12
 * @version:
 */
@RestController
@RequestMapping("/api/v1/user")
public class WmUserController implements WmUserControllerApi {
    @Autowired
    private WmUserService wmUserService;
    /**
     * 保存自媒体用户
     *
     * @param wmUser
     * @return
     */
    @Override
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmUser wmUser) {
        return wmUserService.insert(wmUser);
    }

    /**
     * 按照名称查询用户
     *
     * @param name
     * @return
     */
    @Override
    @GetMapping("/findByName/{name}")
    public WmUser findByName(@PathVariable("name") String name) {
        return wmUserService.findByName(name);
    }

    /**
     * 根据id查询自媒体用户信息
     *
     * @param id
     * @return
     */
    @GetMapping("/findOne/{id}")
    public WmUser findWmUserById(@PathVariable("id")Integer id) {
        return wmUserService.findById(id);
    }
}
